const app = new Vue({
	el: "#app",
	data: {
		msg: "网抑云音乐",
		wd: "",
		songs: [],
		musicUrl: "",
		activeMusicId: null,
		isLoading: false
	},
	methods: {
		playMusic(ID) {
			this.activeMusicId = ID
			this.musicUrl = `https://music.163.com/song/media/outer/url?id=${ID}.mp3`
			// console.log(this.musicUrl)
		},
		handleSearch() {
			if(!this.wd) {
				alert("关键字不能为空")
				return
			}
			this.isLoading = true
			fetch(`https://koo-music.vercel.app/search?keywords=${this.wd}`).then(res => res.json()).then(res => {
				const { songs } = res.result
				this.songs = songs
				console.log(this.songs)
			}).catch(e => {
				console.log(e)
			}).finally(() => {
				this.isLoading = false
			})
		}
	}
})


